<?php
	header('content-type:text/html;charset=utf-8'); 
	
	$dbdata = array();
	$i=-1;
	
	$Str=$_GET["Str"];//字符串
	//从数据库中获取数据，为了节省内存，不要把数据一次性读到内存，从句柄中一行一行读即可 
	
	/* PDO Start */
	$dbName = "sqlsrv:Server=172.31.3.9,1433;Database=UFDATA_001_2017";//emc3030
	$dbUser = "sa";
	$dbPassword = "TDled2017";
	$db = new PDO($dbName, $dbUser, $dbPassword);//這裡是PDO鏈接方法
	
	$sql = 
	"SELECT TOP 1 
		 [cinvcodem]
		,[cinvcode]
		,[CREEJVPN]
		,[KitBinDescription]
		,[BinCode]
		,[MMM]
		,[LL0]
		,[JN]
		,[CCT]
		,[RD]
		,[autoid]
		,[id]
		,[UAPRuntime_RowNO]
		,[UAP_VoucherTransform_Rowkey]
		,[RefMainID]
		,[RefRowID]
	FROM [UFDATA_001_2017].[dbo].[ldx_creebasedtl]
	WHERE [CREEJVPN] ='".$Str."'"
	;
	
	$res = $db->query($sql);
	
	while ($row = $res->fetch()){
		//$i+=1;
		$dbdata[0]=$row['cinvcodem'];
		$dbdata[1]=$row['cinvcode'];
		$dbdata[2]=$row['KitBinDescription'];
		$dbdata[3]=$row['BinCode'];
		$dbdata[4]=$row['MMM'];
		$dbdata[5]=$row['LL0'];
		$dbdata[6]=$row['JN'];
		$dbdata[7]=$row['RD'];
		$dbdata[8]=$row['CREEJVPN'];
	}
	
	//Print array in JSON format
	echo json_encode($dbdata);
	
?>
